package by.alex.dzeshko.facebooksuperclient.async;

import org.json.JSONObject;
import android.util.Log;
import by.alex.dzeshko.facebooksuperclient.R;
import by.alex.dzeshko.facebooksuperclient.async.common.CommonAsyncTask;
import by.alex.dzeshko.facebooksuperclient.async.common.ParamCallback;

public class LoadJsonObjectAsyncTask extends CommonAsyncTask<JSONObject> {

	public LoadJsonObjectAsyncTask(ParamCallback<JSONObject> paramCallback) {
		super(paramCallback);
	}

	@Override
	public JSONObject convert(Object source) throws Exception {
		if (source == null) {
			Log.d("LoadJsObjTask","convert source null");
			return null;
		}
		if(source instanceof String){
			return new JSONObject((String)source);
		}
		if(source instanceof Exception) 
			throw (Exception) source;
		else throw new IllegalStateException();
	}
}
